<html>
<head>
    <meta charset="utf-8">
    <title>后端管理系统</title>
    <link href="https://cdn.bootcss.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<form class="form-horizontal center-block" id="addProblem" method="post" action="/problem/doEdit"
      style="width: 700px ;padding: 10px">
    <input type="hidden" value="${problem.problemDetailId!}" name="id"/>
    <div class="form-group">
        <label class="col-sm-2 control-label">主分支：</label>
        <div class="col-sm-10">
            <select class="form-control" name="mainProblem">
                <#list mainProblem as obj>
                <option value="${obj.mainProblemId!}"
                        <#if problem.mainProblemId==obj.mainProblemId>
                             selected="selected"
                        </#if>
                >${obj.mainProblemName!}</option>
                </#list>
            </select>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-2 control-label">问题：</label>
        <div class="col-sm-10">
            <input type="text" class="form-control" name="problemName" placeholder="请输入问题" value="${problem.problemName}">
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-2 control-label">题型：</label>
        <div class="col-sm-10 select">

            <label class="checkbox-inline"> <input type="radio"
                                                   name="type"
                                                   class="disClass"
                                                    <#if problem.problemType==0>
                                                         checked="checked"
                                                    </#if>
                                                   value="0">单选</label>
                   <label class="checkbox-inline"> <input type="radio"
                                                          name="type"
                                                           <#if problem.problemType==1>
                                                         checked="checked"
                                                           </#if>
                                                          class="disClass"
                                                          value="1">多选</label>
                   <label class="checkbox-inline "> <input type="radio"
                                                          name="type"
                                                            <#if problem.problemType==2>
                                                         checked="checked"
                                                            </#if>
                                                          value="2" class="noclass">评分</label>
                   <label class="checkbox-inline"> <input type="radio"
                                                          class="noclass"
                                                          name="type"
                                                           <#if problem.problemType==3>
                                                         checked="checked"
                                                           </#if>
                                                          value="3">文字</label>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-2 control-label">是否必答：</label>
        <div class="col-sm-10 select">
            <label class="checkbox-inline"> <input type="radio"
                                                   name="must"
                                                    <#if problem.isMust==1>
                                                         checked="checked"
                                                    </#if>
                                                   value="1">必答</label>
            <label class="checkbox-inline"> <input type="radio"
                                                   name="must"
                                                     <#if problem.isMust==0>
                                                         checked="checked"
                                                     </#if>
                                                   value="0">不必答</label>
        </div>
    </div>

    <div class="form-group removeClass" id="append" <#if problem.problemType==0 ||problem.problemType==1> style="display: block" <#else >style="display: none" </#if>>
        <#list problem.problemOptionDTOList as option>
        <div>
            <label class="col-sm-2 control-label">选项${option_index+1}：</label>
            <div class="col-sm-10">
                <input type="text" class="form-control" name="${option_index+1}" value="${option.optionName}">
            </div>
        </div>
        </#list>
    </div>
    <div class="form-group text-center" id="sub" style="margin-top: 5px">
        <button type="submit" class="btn btn-success radius">确定</button>
    </div>
</form>

<button type="button" class="btn btn-default pull-right removeClass " onclick="add(2)" <#if problem.problemType==0 ||problem.problemType==1>style="margin-right: 80px ;display: block" <#else> style="margin-right: 80px ;display: none" </#if>>添加选项</button>

<script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script>
<script src="http://malsup.github.com/jquery.form.js"></script>
<script src="https://cdn.bootcss.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<script type="text/javascript" src="../js/static/layer/layer.js"></script>
<script type="text/javascript" src="../js/static/common.js"></script>
<script src="../js/static/jquery.validation/1.14.0/jquery.validate.js"></script>
<script src="../js/static/jquery.validation/1.14.0/validate-methods.js"></script>
<script src="../js/static/jquery.validation/1.14.0/messages_zh.js"></script>
<script type="text/javascript" src="../js/problem_edit.js"></script>
<script>
    var i = ${problem.problemOptionDTOList?size!};

    function add() {
        i++;
        if(i > 10) {
            alert("最多添加10项");
        } else {
            $("#sub").remove();
            $("#append").append(' <label for="inputEmail3" class="col-sm-2 control-label" style="margin-top: 5px">选项' + i + '：</label> <div class="col-sm-10" style="margin-top: 5px"> <input type="text" class="form-control" id="inputEmail3"  name=' + "" + i + '> </div> </div><div class="form-group  text-center " id="sub" style="margin-top: 5px">  <button onclick="sub()" style="margin-top: 5px" class="btn btn-success radius">确定</button>');
        }
    }

</script>
</body>
</html>